package com.sitech.ibnms.c3p.mappers;

import com.sitech.ibnms.c3p.command.IOParamType;
import com.sitech.ibnms.c3p.domain.C3pTaskNodeIo;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 任务节点输入输出参数表
 * Created by liujhc on 7/14.
 */
public interface C3pTaskNodeIOMapper {

    List<C3pTaskNodeIo> queryParamsOut(@Param("serialNo") int serialNo, @Param("excludePrefix") String excludePrefix);

    C3pTaskNodeIo queryParamInByName(@Param("serialNo") int serialNo, @Param("activityId") int activityId, @Param("paramName") String paramInName);

    Integer queryIntegerByParamNameAndParamType(@Param("taskId") int taskId,
                                              @Param("paramName") String paramName,
                                              @Param("paramType") IOParamType paramType);

    int queryRootSerialNo(@Param("serialNo") int serialNo);

    int updateCompleteResourceCount(@Param("taskId") int taskId, @Param("paramName") String paramName);

    int findNodeExecuteFailCount(@Param("taskId") int taskId, @Param("paramName") String paramName);

    /**
     * 递归获取所有当前实例及子实例的参数
     *
     * @param rootSerialNo
     * @param paramName
     * @param paramType
     * @return
     */
    @SuppressWarnings("MybatisMapperMethodInspection")
    List<C3pTaskNodeIo> queryParamValuesRecursively(@Param("rootSerialNo") int rootSerialNo,
                                         @Param("paramName") String paramName,
                                         @Param("paramType") IOParamType paramType);

    void insertParam(@Param("params") List<C3pTaskNodeIo> params);

    int selectParamByActivityNotExecutePolicy(@Param("serialNo") Integer serialNo, @Param("activityId") Integer activityId);

    int deletePolicyParamNotExecute(@Param("serialNo") Integer serialNo);

    void insertToHisByRootSerialNo(@Param("rootSerialNo") int rootSerialNo);
    void deleteByRootSerialNo(@Param("rootSerialNo") int rootSerialNo);
}
